var searchParam_content=null;
var myScroll_searchEmp=null;
$( document ).on( "pagecreate", "#searchEmp", function( event ) {
	access_token=getQueryString("access_token");
	
	document.getElementById("wrapper_searchEmp").style.bottom="0px";
	
	myScroll_searchEmp = new iScroll("wrapper_searchEmp", {scrollbarClass: 'myScrollbar'});
	//加载该员工所在部门员工
	searchLoadEmpInfo_searchEmp(searchParam_content,myScroll_searchEmp);
	//绑定查询按钮事件
	$( "#searchEmp_search" ).on("click",function (){
		searchParam_content=$("#searchEmp_content").val();
		searchLoadEmpInfo_searchEmp(searchParam_content,myScroll_searchEmp);
	});
});

$( document ).on( "pageshow", "#searchEmp", function( event ) {
	var height=document.getElementById('container_searchEmp').offsetTop+10;
	$("#wrapper_searchEmp").css({"top":height+"px"});
});


function searchLoadEmpInfo_searchEmp(content,myScroll_searchEmp){
	var param="access_token="+access_token+"&content="+content;
	if(content==undefined || content==null || content==""){
		param="access_token="+access_token;
	}
	$.ajax({
	  	url: rootPath+"/user/searchEmpInfo.do",
	  	type: "POST",
	  	dataType: "text",
		data: param,
	  	success: function( response ) {
	  		var data=$.parseJSON(response);
	  		
			if(data.state=="200"){
//				var totalPage=data.data.totalPage;
//		  		var totalRow=data.data.totalRow;
		  		var arr=data.data;
		  		
				var content = "";
				for (var i=0;i<arr.length;i++){
					var headerPic=rootPath+defaultHeadPic;
					if(arr[i].headImageUrl!=undefined && arr[i].headImageUrl!="")
						headerPic=arr[i].headImageUrl;
					var toPage=rootPath+"/jsp/weixin/otherPersonInfo.jsp?empId="+arr[i].empId+"&access_token="+access_token;
					content+='<li>\
							<div class="person_info person_head_0">\
							<img src="'+headerPic+'" onClick="goTo(\''+toPage+'\')" />\
								<span class="personname_bg">\
									<span class="person_name">'+arr[i].empName+'</span>\
								</span>\
							</div>\
						</li>';
					$("#searchContentList").html("").append(content);
					myScroll_searchEmp.refresh();
				}
			}else{
				alert_wx('fail',data.msg);
			}
	  	}
	});
}